package com.example.keli.ui.home.activity;

import android.content.Context;
import android.content.Intent;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;

import butterknife.BindView;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

public class VideoActivity extends BaseActivity {

    @BindView(R.id.video_player)
    JCVideoPlayerStandard mVideoPlayer;

    public static void start(Context context,String url){
        Intent intent = new Intent(context,VideoActivity.class);
        intent.putExtra("video_url",url);
        context.startActivity(intent);
    }
    @Override
    protected int layoutId() {
        return R.layout.activity_video;
    }

    @Override
    protected void bindData() {
        mVideoPlayer.setUp(getIntent().getStringExtra("video_url"), JCVideoPlayer.SCREEN_LAYOUT_LIST, "");
        mVideoPlayer.seekToInAdvance = 0;//设置进度
        mVideoPlayer.startVideo();
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }
}
